﻿using Microsoft.AspNetCore.Components.Forms;

namespace BlazorApp.Client;
public class FormCssClassProvider
    :Microsoft.AspNetCore.Components.Forms.FieldCssClassProvider
{
    public override string GetFieldCssClass(EditContext editContext, in FieldIdentifier fieldIdentifier)
    {
        if (!editContext.IsModified())
        {
            return string.Empty;
        }

        var valid = editContext.IsValid(fieldIdentifier);
        return valid ? "is-valid" : "is-invalid";
    }
}
